const API = require('./base')

export function getRandPosts(data) {
  return API.get('/wp-json/mp/v2/posts?orderby=rand', data);
}


export function getPostsList(data){
  return API.get('/wp-json/mp/v2/posts', data, {
    token: true
  });
}

export function  getCategories (data) {
  return API.get('/wp-json/wp/v2/categories?orderby=id&order=asc&per_page=20&hide_empty=true', data);
}


export function  getPostsbyID(id) {
  return API.get('/wp-json/mp/v2/posts/' + id, {}, {
    token: true
  });
}

export function getCategoryByID(id) {
  return API.get('/wp-json/wp/v2/categories/' + id);
}



export function getRelatePost(id){
  return API.get('/wp-json/mp/v2/posts?custom=relate&id=' + id);
}

export function  getUserPosts(id, page) {
  return API.get('/wp-json/mp/v2/posts?author=' + id + '&page=' + page);
}

/**
 * 获取直播接口
 */

export function getLiveLists(args){
  return API.post('/wp-json/mp/v2/miniprogram/live', args, {
    token: true
  });
}

/**
 * 获取回放接口
 */

export function getReplays   (args) {
  return API.post('/wp-json/mp/v2/miniprogram/replay', args, {
    token: true
  });
}